package com.example.auth.controller;

import com.example.auth.feign.IndexClient;
import com.example.util.model.PrivilegeUser;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;

//@RestController
@Controller
@RequestMapping("/")
public class IndexController {
    private static final Logger LOG = LoggerFactory.getLogger(IndexController.class);
    @Autowired
    private IndexClient indexClient;

    @GetMapping(value = "/index")
    public  String index(){
        return "hello world !";
    }
    @RequestMapping(value = "/login",method =RequestMethod.GET)
//    @GetMapping(value = "/login")
    public  String login(ModelAndView modelAndView){
//        return "hello ，登录成功！";
        ResponseEntity<PrivilegeUser> user = indexClient.hello("admin");
        modelAndView.addObject("user",user.getBody());
        return "login";
    }
}
